/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hva.web.mvcwebapp.models;
import java.util.Date;
 
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
 
@Entity
@Table(name = "user_course")
@AssociationOverrides({
		@AssociationOverride(name = "pk.user", 
			joinColumns = @JoinColumn(name = "USER_ID")),
		@AssociationOverride(name = "pk.course", 
			joinColumns = @JoinColumn(name = "COURSE_ID")) })
public class CourseUser implements java.io.Serializable {
 
	private UserCoursePK pk = new UserCoursePK();

 
	public CourseUser() {
	}
 
	@EmbeddedId
	public UserCoursePK getPk() {
		return pk;
	}
 
	public void setPk(UserCoursePK pk) {
		this.pk = pk;
	}
 
	@Transient
	public User getUser() {
		return getPk().getUser();
	}
 
	public void setUser(User user) {
		getPk().setUser(user);
	}
 
	@Transient
	public Course getCourse() {
		return getPk().getCourse();
	}
 
	public void setCourse(Course course) {
		getPk().setCourse(course);
	}
 
 
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;
 
		CourseUser that = (CourseUser) o;
 
		if (getPk() != null ? !getPk().equals(that.getPk())
				: that.getPk() != null)
			return false;
 
		return true;
	}
 
	public int hashCode() {
		return (getPk() != null ? getPk().hashCode() : 0);
	}
}